package com.imcode.exceptiondemo;

public class ExceptionDemo03 {

    public static void main(String[] args) {
        test01(10);
    }

    public static void test01(int i) {
        try {
            i = 100/0;

            int r = 0;
            int[] arr = new int[10];
            //arr = null;
            arr[i] = 100;
            r = arr[i];
            System.out.println("r = " + r);
        }
        //catch (ArrayIndexOutOfBoundsException e){
        //catch (NullPointerException e){
        //catch (Exception e){
        //    e.printStackTrace();// 在控制台打印输出异常信息
        //}
        catch (ArrayIndexOutOfBoundsException e1){
            e1.printStackTrace();
        }
        catch (NullPointerException e2){
            e2.printStackTrace();
        }

        catch (Exception e){
            e.printStackTrace();
        }
    }
}
